package com.sojpt.boot.controller.business.validator;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;
import com.sojpt.model.LkyTeacher;

public class LkyTeacherUpdateValidator extends Validator {

    @Override
    protected void validate(Controller c) {

        LkyTeacher lkyTeacher = c.getModel(LkyTeacher.class, "lkyTeacher");

        if(lkyTeacher.get("name") != null)
            validateString("lkyTeacher.name", 0, 32, "msg", "姓名 最多32个字符");
        validateRequired("lkyTeacher.name", "msg", "请输入姓名");
        if(lkyTeacher.get("email") != null)
            validateString("lkyTeacher.email", 0, 50, "msg", "邮箱 最多50个字符");
        if(lkyTeacher.get("native_place") != null)
            validateString("lkyTeacher.native_place", 0, 50, "msg", "籍贯 最多50个字符");
        if(lkyTeacher.get("remark_info") != null)
            validateString("lkyTeacher.remark_info", 0, 50, "msg", "备注信息 最多50个字符");
        if(lkyTeacher.get("job_number") != null)
            validateString("lkyTeacher.job_number", 0, 20, "msg", "工号 最多20个字符");
        validateRequired("lkyTeacher.job_number", "msg", "请输入工号");

    }

    @Override
    protected void handleError(Controller c) {
        c.renderJson();
    }

}